package com.wasion.gydpe.service.impl;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Service;

import com.wasion.gydpe.common.util.MD5Util;
import com.wasion.gydpe.dao.WelcomeDao;
import com.wasion.gydpe.exception.DataAccessException;
import com.wasion.gydpe.model.Resource;
import com.wasion.gydpe.service.WelcomeService;

/**
 * 
 * @ClassName: WelcomeServiceImpl
 * @Description: 用户登录数据初始化等业务层实现ServiceImpl
 * @author 高意
 * @date Sep 25, 2012 10:10:50 AM
 * 
 */
@Service
public class WelcomeServiceImpl implements WelcomeService {

	@javax.annotation.Resource
	private WelcomeDao welcomeDao;

	public List<Resource> queryResources(Map<String, Object> paramMap)
			throws DataAccessException {
		return welcomeDao.queryResources(paramMap);
	}

	public boolean login(Map<String, Object> paramsMap)
			throws DataAccessException {

		String pwd = (String) paramsMap.get("pwd");
		//pwd = MD5Util.MD5(pwd);
		paramsMap.put("pwd", pwd);

		boolean isSucc = welcomeDao.login(paramsMap);

		HttpServletRequest request = ServletActionContext.getRequest();
		request.getSession()
				.setAttribute("username", paramsMap.get("username"));
		request.getSession().setAttribute("isSucc", isSucc);
		return isSucc;
	}
}
